/**
 * Created by Administrator on 14-4-26.
 */
$(document).ready(function(){
    $('.about_ques .hd ul li').mousemove(function(){
        $('.about_ques .hd ul li').removeClass('on');
        $(this).addClass('on');
        $('.about_ques .bd .pan').hide();
        var liIndex=$(this).index();
        $('.about_ques .bd .pan').eq(liIndex).show();
    });
    $('.news_pan .hd ul li').mousemove(function(){
        $('.news_pan .hd ul li').removeClass('on');
        $(this).addClass('on');
        $('.news_pan .bd .pan').hide();
        var liIndexT=$(this).index();
        $('.news_pan .bd .pan').eq(liIndexT).show();
    });
    $('.AA').click(function(){
        $('#formOne').show();
        return false;
    });
    $('.BB').click(function(){
        $('#formTwo').show();
        return false;
    });
    $('.CC').click(function(){
        $('#formThree').show();
        return false;
    });
    $('.DD').click(function(){
        $('#formFour').show();
        return false;
    });
    $('.sites').hover(function(){
        $('#webs').show();
    },function(){
        $('#webs').hide();
    })
    $(".adThree").each(function() {
        $(this).find("a").eq(3).addClass("last");
    })
});
/*
 * 追加提问
 */
function addquestion(replyid,obj,lawyerid){
	var html = '<form action="/index.php?m=content&c=answer&a=append_ask" method="post"><div class="addAskFormItem">'+
		'<input type="hidden" name="id" value="'+replyid+'"/>'+
		'<input type="hidden" name="quesid" value="'+quesid+'"/>'+
		'<input type="hidden" name="username" value="'+senduser+'"/>'+
		'<input type="hidden" name="type" value="ask" />'+
		'<input type="hidden" name="lawyerid" value="'+lawyerid+'"/>'+
        '<textarea cols="" rows="" name="content"></textarea>'+
        '</div>'+
        '<div class="addAskFormItem">'+
            '<input type="submit" value="追加提问"/>'+
        '</div></form>';
	obj.parent().parent().next().empty().append(html);
}
/*
 * 追加回复
 */
function supperanswer(replyid,obj){
	var html = '<form action="/index.php?m=content&c=answer&a=supply_answer" method="post"><div class="addAskFormItem">'+
	'<input type="hidden" name="id" value="'+replyid+'"/>'+    
	'<textarea cols="" rows="" name="content"></textarea>'+
        '</div>'+
        '<div class="addAskFormItem">'+
            '<input type="submit" value="追加回复"/>'+
        '</div></form>';
	obj.parent().parent().next().empty().append(html);
}
/*
 * 修改回复内容
 */
function editanswer(replyid,obj){
	var content = $("#content_"+replyid).html();
	var html = '<form action="/index.php?m=content&c=answer&a=supply_answer" method="post"><div class="addAskFormItem">'+
	'<input type="hidden" name="id" value="'+replyid+'"/>'+    
	'<textarea cols="" rows="" name="content">'+content+'</textarea>'+
        '</div>'+
        '<div class="addAskFormItem">'+
            '<input type="submit" value="修改回复"/>'+
        '</div></form>';
	obj.parent().parent().next().empty().append(html);
}
/*
 * 设为最佳答案
 */
function bestanswer(replyid){
	if(confirm("您确定采纳此律师的回复为最佳答案吗?")){
		$.ajax({
			  type: 'POST',
			  url: "/index.php?m=content&c=question&a=best&id=" +id +'&qid=' + qid + '&siteid='+ siteid + '&catid=' + catid,
		  	  data : "uid=" + uid + "&price=" + price + '&username=' + username + '&rid=' + rid + '&assess=' + assess,
			  success: function(data){
				  shuaxin();
				  if(data=='success'){
					  $("#bbest_" + id).hide();
					  //reviews(id,qid,siteid,catid,uid,username,rid);
					  //$('#reviews_'+id).prepend('<p><font color="red" size="2">您已经选择律师的回复为最佳答案，请您对律师的回复做出评价</font></p>');

				  }
			  },
			  dataType: 'html'
			});					
	}
	return;	
	  var str = "<form><input type='button' value='最佳答案' id='bbest_" + id + "'/></form>";
	  $('#best_'+id).html(str).toggle();
		$("#bbest_" + id).click(function(){
		});	
}

function  shuaxin(){
	location.reload();
}

$(function(){
    img_w=$(".pr_adT>ul>li").find("img").width();
    num=$(".pr_adT>ul>li").length;
    mr_left=Math.floor((750-(num*img_w))/(num-1));
    $(".pr_adT>ul>li").eq(0).siblings().find("img").css("margin-left",mr_left);
})

function bookmark(title, url) {
    if(document.all) { // ie
        window.external.AddFavorite(url, title);
    }else if(window.sidebar) { // firefox
        window.sidebar.addPanel(title, url, "");
    }else if(window.opera && window.print) { // opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click(); // this.title=document.title;
    }else{
        alert("加入收藏失败，请使用Ctrl+D进行添加");
    }
}